// pages/tab/index.js

const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    deviceInfo: {
      electricity: 22.2,
      mileage: 0
    },
    controlList: [{
      src: 'bellring-on',
      name: '寻车'
    }, {
      src: 'lock',
      name: '车辆上锁'
    }, {
      src: 'link',
      name: '车辆解锁'
    }],
    serveList: [{
      src: '/image/riding-car.png',
      name: '导航到车'
    }, {
      src: '/image/riding-car.png',
      name: '车辆设置'
    }, {
      src: '/image/riding-car.png',
      name: '钥匙分享'
    }],
    bluetoothDevice: app.globalData.bluetoothDevice,
    isMovableDeviceSwith: false,
    switchImageSrc: '/image/device/swith-car.png',
    movableAreatext: '右滑启动车辆',
    /* new TMap.LatLng(40.04549968987281, 116.30132245232517 */
    electronicFenceLogitud: 116.26174449920654,
    electronicFenceLatitude: 40.03854009824492,
    electronicFencePolygons: [{
      dashArray: [5, 10], //边线虚线
      points: [{
        latitude: 40.03854009824492,
        longitude: 116.26174449920654
      }, {
        latitude: 40.041117253378246,
        longitude: 116.2722415837743
      }, {
        latitude: 40.03870438053774,
        longitude: 116.26341819763184
      }, {
        latitude: 40.038342958971086,
        longitude: 116.26384735107422
      }, {
        latitude: 40.037882965115706,
        longitude: 116.26423358917236
      }, {
        latitude: 40.03768582394209,
        longitude: 116.2642765045166
      }, {
        latitude: 40.037455825185845,
        longitude: 116.26311779022217
      }, {
        latitude: 40.037258682777356,
        longitude: 116.26328945159912
      }, {
        latitude: 40.03719296851454,
        longitude: 116.26243114471436
      }, {
        latitude: 40.037488682198514,
        longitude: 116.26165866851807
      }, {
        latitude: 40.03791582192258,
        longitude: 116.26208782196045
      }, {
        latitude: 40.038178675807515,
        longitude: 116.26140117645264
      }, {
        latitude: 40.03847438521698,
        longitude: 116.26140117645264
      }],
      strokeColor: '#000000',
      strokeWeight: 1,
      fillColor: '#ffffff',
      zIndex:99999,
      level:'abovelabels'
    }],
    electronicFenceMarker:[],
    ridingMilege: [{
      src: 'link',
      name: '里程数',
      value: ''
    }, {
      src: 'time',
      name: '骑行时间',
      value: ''
    }, {
      src: 'discover',
      name: '平均速度',
      value: ''
    }]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },
  /* 滑动启动车辆 */
  movableChange: function (e) {
    let x = e.detail.x
    if (x >= 152) {
      this.setData({
        isMovableDeviceSwith: true,
        switchImageSrc: '/image/device/swith-car-true.png',
        movableAreatext: '左滑关闭车辆'
      })
    } else if (!x) {
      this.setData({
        isMovableDeviceSwith: false,
        switchImageSrc: '/image/device/swith-car.png',
        movableAreatext: '右滑启动车辆'
      })
    }
  }
})